/**
 * 表单验证
 * 
 * @param {Object} rules 验证字段的规则
 * @param {Object} messages 验证字段的提示信息
 * 
 */

import basic from '../../../xc/model/basic.js';
var actmodel = new basic();


actmodel.offset = function (that, reset, para, xcsorts) { 
  if(!xcsorts)
  {
    xcsorts=[["id", "desc"], ["modifytime", "desc"]] ;
  }
 
  var acturlpara = {};   
  acturlpara["url"] = "entry/wxapp/order_inquirybill"
  if (para) {
    para["op"] = "offset"
  }
  else {
    this.wherepara["op"] = "offset"
  }
  return actmodel.pagelist(acturlpara, that, reset, para, xcsorts);
}

//创建定金订单
actmodel.orderop = function (opname,id) {
  var app = getApp();
  var data = { "op": "orderop",opname,id }
  return new Promise((resolve, reject) => {
    app.util.request({
      'url': 'entry/wxapp/order_inquirybill',
      'data': data,
      'method': "get",
      success: function (res) {
        if (res.data.errno == 0) {

          resolve(res.data.data);

        }
        reject(res.data.message);
      },
      fail: function (res) {

        reject(((res.data && res.data.message) ? res.data.message : res.errMsg));
      },
      complete: function () {
      }
    });
  });
}

//支付订单
actmodel.orderpay=function (opname,id) {
  var app = getApp();
  var data = { "op": "orderpay", id,opname}
  return new Promise((resolve, reject) => {
    app.util.request({
      'url': 'entry/wxapp/order_inquirybill',
      'data': data,
      'method': "post",
      'showLoading':true,
      success: function (res) {
        if (res.data.errno == 0) {

          resolve(res.data.data);

        }
        reject(res.data.message);
      },
      fail: function (res) {

        reject(((res.data && res.data.message) ? res.data.message : res.errMsg));
      },
      complete: function () {
      }
    });
  });
}

//创建定金订单
actmodel.createdepositorder = function (model) {
  var app = getApp();
  var data = { "op": "createdepositorder", model: model }
  return new Promise((resolve, reject) => {
    app.util.request({
      'url': 'entry/wxapp/order_inquirybill',
      'data': data,
      'method': "get",
      success: function (res) {
        if (res.data.errno == 0) {

          resolve(res.data.data);

        }
        reject(res.data.message);
      },
      fail: function (res) {

        reject(((res.data && res.data.message) ? res.data.message : res.errMsg));
      },
      complete: function () {
      }
    });
  });
}

actmodel.queryorder=function (id,status) {

  var app = getApp();
  var data = { "op": "queryorder", id: id,status}
  return new Promise((resolve, reject) => {
    app.util.request({
      'url': 'entry/wxapp/order_inquirybill',
      'data': data,
      'method': "post",
      success: function (res) {
        
        resolve(res.data.data);
      }
    })
})
}



module.exports = actmodel;